/*给服务器发送一个数据，告诉服务器要发送1024字节的数据，但是实际发送的数据不足1024，查看服务器处理结果*/
/*
1.如果数据只发送一次，服务器将得不到完整请求，就不会进行业务处理，客户端也就得不到响应，最终超时关闭连接
2.连着给服务器发送了多次小请求，服务器会将后边的请求当做前边请求的正文进行处理，而后便处理的时候有可能因为处理错误而关闭连接
*/

#include <iostream>

#include "../source/Server.hpp"

int main()
{
    TcpSocket client;
    client.BulidClientSocket("127.0.0.1", 8888);
    std::string req = "GET /hello HTTP/1.1\r\nConnection: keep-alive\r\nContent-Length: 100\r\n\r\nnihaoya";
    while (true)
    {
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        assert(client.Send(req) != -1);
        std::string out;
        assert(client.Recv(&out));
        DEBUG_LOG("[%s]", out.c_str());
        sleep(15);
    }
    return 0;
}